package com.sunedai.tiger.common.utils;

import java.io.File;
import java.io.IOException;

import net.coobird.thumbnailator.Thumbnails;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * 图片工具类
 * @author zhaolipeng
 */
public class ImagesUtils {
  private static Log log = LogFactory.getLog(ImagesUtils.class);
  
  public static void createThumbnails(int width, int height, File picFile){
  	try {
	    Thumbnails.of(picFile)
	    					.size(width, height)
	    					.keepAspectRatio(false)
	    					.outputQuality(0.8)
	    					.toFile(picFile);
    } catch (IOException e) {
    	log.error("图片处理失败" + e.getMessage());
	    e.printStackTrace();
    }
  }

	public static void createThumbnails(File picFile){
		try {
			Thumbnails.of(picFile)
							.scale(1f)
							.outputQuality(0.8)
							.toFile(picFile);
		} catch (IOException e) {
			log.error("图片处理失败" + e.getMessage());
			e.printStackTrace();
		}
	}
}
